﻿<!-- #include file="function.asp" -->
<%
'注册插件
Call RegisterPlugin("xnxf_zhizhu","ActivePlugin_xnxf_zhizhu")
'挂口部分
Function ActivePlugin_xnxf_zhizhu()

	Call Add_Action_Plugin("Action_Plugin_Edit_Article_Begin","Call zz_addForm()")

	Call Add_Filter_Plugin("Filter_Plugin_PostArticle_Succeed","zz_ping")
	'Call Add_Action_Plugin("Action_Plugin_MakeFileReBuild_End","Call ExportSiteMap")
	
End Function

Function zz_addForm()
  Dim ischeck
  Call InstallPlugin_xnxf_zhizhu()
  ischeck = IIf(zz_ato,"checked","")
  Call Add_Response_Plugin("Response_Plugin_Edit_Form3","<p><label><span class='editinputname'>云蜘蛛:<input type=""checkbox""  name=""zz_ping"" id=""zz_ping"" onclick="""" value=""True"" "&ischeck&" /></label></span></p>")
End Function

Dim zz_ID,zz_Key

zz_ID = "5803303562830824448"
zz_Key = "8f17bd1b265f49ee9594d126f2744b21"

'发送数据
Function zz_ping(ByRef obj)
  Call InstallPlugin_xnxf_zhizhu()
  If Request.Form("zz_ping") <> "True" Then Exit Function
	Dim xmlhttp
	Set xmlhttp=Server.CreateObject("MSXML2.ServerXMLHTTP")
	xmlhttp.Open "POST","http://zhizhu.yun2030.com/api/submit?u="&zz_usr&"&p="&zz_pwd&"&appid="&zz_ID&"&appkey="&zz_Key&"&urls="&Server.URLEncode(obj.HtmlUrl),false	
  xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=utf-8"
	xmlhttp.send()
  'zz_ping = xmlhttp.responseText
	Set zz_ping=toObject(xmlhttp.responseText)
  Call SaveToFile(BlogPath&"zb_users/PLUGIN/xnxf_zhizhu/log.txt",xmlhttp.responseText&Server.URLEncode(obj.HtmlUrl),"UTF-8",False)
  If zz_ping.ok = false Then
    Call SetBlogHint_Custom(zz_ping.msg&"<a href=""http://zhizhu.yun2030.com/register?u=wdssmq"" target=""_blank"" title=""点击这里注册或充值"">点击这里注册或充值</a>")
	End If
  Set xmlhttp=Nothing
End Function

Dim zz_cfg,zz_usr,zz_pwd,zz_ato

Function InstallPlugin_xnxf_zhizhu()
  Set zz_cfg = New TConfig
  zz_cfg.Load "xnxf_zhizhu"
	If zz_cfg.Exists("pwd")=False Then
    zz_cfg.Write "usr",""
    zz_cfg.Write "pwd",""
    zz_cfg.Write "ato",False
    zz_cfg.Save
  End If
  zz_usr = zz_cfg.Read("usr")
  zz_pwd = zz_cfg.Read("pwd")
  zz_ato = CBool(zz_cfg.Read("ato"))
End Function


Function UnInstallPlugin_xnxf_zhizhu()

	'用户停用插件之后的操作
	
End Function
%>
<script language="javascript" type="text/javascript" runat="server">
  function toObject(json) {
    eval("var o=" + json);
  return o;
  }

  function getItem(obj,Num,Name){
    return obj[Num][Name];
  }
</script>